//
//  NewDetailViewController.m
//  New
//
//  Created by dlios on 15-7-18.
//  Copyright (c) 2015年 yangTao. All rights reserved.
//

#import "NewDetailViewController.h"

@interface NewDetailViewController ()

@end

@implementation NewDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem *button = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"iconfont-fanhuijian.png"] style:UIBarButtonItemStylePlain target:self action:@selector(ButtonAction)];
    self.navigationItem.leftBarButtonItem = button;
    self.navigationItem.title =@"详情";
    
    
    self.scrol = [[NewDetailScrollView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-22-44-49)];
    self.scrol.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.scrol];
//    self.scrol.contentSize = CGSizeMake(WITH, 2*HEIHT);
    [self reloadValue];
    [self getInFo];
    
    // Do any additional setup after loading the view.
}


-(void)getInFo{

    AFNetworkReachabilityManager *netWorkManager = [AFNetworkReachabilityManager sharedManager];
    NSString *url_string = [NSString stringWithFormat:@"http://api.wallstreetcn.com:80/v2/posts/%@",self.ID];
   
    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    [manager GET:url_string parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [netWorkManager stopMonitoring];
        // 拿到当前的下拉刷新控件，结束刷新状态
        
        [self.MBHUD hide:YES];
        
        
        self.scrol.dic = responseObject;
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"失败==== %@",error);
        // 拿到当前的下拉刷新控件，结束刷新状态
        
        [self.MBHUD hide:YES];
        UIAlertView *alView = [[UIAlertView alloc]initWithTitle:@"网络不给力" message:@"确认您已连接到网络" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alView show];

    }];
    



}
-(void)reloadValue {
    self.MBHUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    self.MBHUD.labelText = @"正在加载中...";
    [self.MBHUD show:YES];
   

}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
 [self.navigationController popViewControllerAnimated:YES];

}


-(void)ButtonAction{

    [self.navigationController popViewControllerAnimated:YES];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
